
               select 
               trunc(E.MOV_Dt) data_movimento,
              
               SUM(nvl(E.SCR_IMP_D,0)) dare,
               SUM(nvl(E.SCR_IMP_A,0)) avere
               from (
               SELECT CSI_IDCLI,PAR_ID FROM (
               SELECT CSI_IDCLI,PAR_ID,SUM(NVL(SCR_IMP_D,0))-SUM(NVL(SCR_IMP_a,0)) XX FROM V_SCRITTURADEST_EC WHERE AZ_ID ='01' GROUP BY CSI_IDCLI,PAR_ID)
               WHERE XX <> 0) E1, V_SCRITTURADEST_EC E,   
                           
               SOGGETTO S,FATTURAT F
               where E.AZ_ID = S.AZ_ID
               and   e.az_id = f.az_id(+)
               and   E.CSI_IDCLI = S.CSI_ID
               and   s.az_id = '01'
               AND  E.TFAT_ID = F.TFAT_ID(+)
               AND E.CSI_IDCLI=E1.CSI_IDCLI
               AND E.PAR_ID=E1.PAR_ID
               and e.mov_dt >= to_date(^Da data movimento gg/mm/aaaa;A;Alfanumerico^^,'dd/mm/yyyy')
               and e.mov_dt <= to_date(^ A data movimento gg/mm/aaaa;A;Alfanumerico^^,'dd/mm/yyyy')
              -- and e.mov_dt >= to_date('01/01/2006','dd/mm/yyyy')
           
               GROUP BY 
               
               E.MOV_Dt
               
               order by e.mov_dt
               
               
               
               
 
               
               
               
               